package com.soft.util;

/**
 */
import javax.servlet.http.HttpServletRequest;


public class HandlePn {
	
	public static int pagemax = 10;

	public static int getRequestInt(HttpServletRequest request, String str) {
		return getRequestInt(request, str, 1);
	}

	public static int getRequestInt(HttpServletRequest request, String str, int dfi) {
		String strPN = request.getParameter(str);
		int k = dfi;
		try {
			k = Integer.parseInt(strPN);
		} catch (Exception e) {
		}
		return k;
	}

	
	public static int getPageMax(int count, int num) {

		int k = count / num;
		if (count % num > 0) {
			k = k + 1;
		}
		if (count == 0)
			k = 0;
		return k;
	}

	public static int getPageMax1(int count, int num) {

		int k = (count / num) / 6;
		if (count % num > 0) {
			k = k + 1;
		}
		if (count == 0)
			k = 0;
		return k;
	}

	
	public static int getPrevious(int pn) {
		int k = 0;
		if (pn <= 1) {
			k = 1;
		} else
			k = pn - 1;
		return k;
	}

	public static int getNext(int pn, int max) {
		int k = max;
		if (pn < max) {
			k = pn + 1;
		}
		return k;
	}

	
	public static String getPreviousJobnote(int pn) {
		if (pn == 0)
			return "上�??�?";
		else
			return "<a href=\"#\" onclick='return gotoPage(" + HandlePn.getPrevious(pn) + ")'>上�??�?</a>";
	}

	
	public static String getNextJobnote(int pn, int maxpage) {

		
		if (pn + 1 >= maxpage) {
			return "下�??�?";
		} else
			return "<a href=\"#\" onclick='return gotoPage(" + HandlePn.getNext(pn, maxpage) + ")'>下�??�?</a>";
	}
	public static void main(String[] args) {
		System.out.println(HandlePn.getPageMax(101,10));;
	}

}
